package interfaces

import (
	"gitee.com/captials-team/ubdframe/src/domain/dto/paginate"
	"gorm.io/gorm"
)

type GormApplyQuery func(*gorm.DB) *gorm.DB

type DBFacade[T interface{}] interface {
	All(scopes ...GormApplyQuery) ([]*T, error)                                        //查询所有
	Search(pa *paginate.Pager, apply ...GormApplyQuery) ([]*T, *paginate.Pager, error) //分页查询
	Query(id int64) (*T, error)                                                        //查询指定id的单条记录
	Add(T) (int64, error)                                                              //添加记录
	Update(id int64, up T) (int64, error)                                              //更新记录
	Delete(id int64) (int64, error)                                                    //删除记录
	ResetStatus(id int64, status int) (int64, error)                                   //重置status

	QueryByScope(apply ...GormApplyQuery) (*T, error) //自定义scope查询单条记录
	DeleteByScope(scopes ...GormApplyQuery) (int64, error)

	UseDB(db *gorm.DB) DBFacade[T] //使用db

	ItfMigrate
	ItfGormDB
}
